package com.kanshu.ksgb.fastread.doudou.module.book.adapter;

import android.content.Context;

import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.app.constants.ARouterConfig;
import com.kanshu.ksgb.fastread.doudou.base.baseadapter.abslistview.CommonAdapter;
import com.kanshu.ksgb.fastread.doudou.base.baseadapter.abslistview.ViewHolder;
import com.kanshu.ksgb.fastread.doudou.common.imageloader.GlideImageConfig;
import com.kanshu.ksgb.fastread.doudou.common.imageloader.GlideImageLoader;
import com.kanshu.ksgb.fastread.doudou.common.util.ARouterUtils;
import com.kanshu.ksgb.fastread.doudou.module.book.bean.CategoryBean;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 分类列表适配器
 * Created by wcy on 2017\7\14 0014.
 */
public class SubCategoryGridAdapter extends CommonAdapter<CategoryBean> {
    GlideImageConfig emptyConfig = GlideImageLoader.getEmptyConfig();
    public SubCategoryGridAdapter(Context context, int layoutId, List<CategoryBean> datas) {
        super(context, layoutId, datas);
    }
    @Override
    protected void convert(ViewHolder holder, final CategoryBean item, final int position) {
        GlideImageLoader.load(item.category_img, holder.getView(R.id.cover), emptyConfig);
        holder.getConvertView().setOnClickListener(v -> {
//              public static final String EXTRA_TITLE = "title";
//    public static final String EXTRA_CATEGORY_ID_1 = "category_id_1";
//    public static final String EXTRA_CATEGORY_ID_2 = "category_id_2";
//    public static final String EXTRA_SITE = "site";
            // TODO: 分类列表
            Map<String, String> map = new HashMap<>();
            map.put("title", item.short_name);
            map.put("category_id_1", item.category_id);
            map.put("category_id_2", "");
            map.put("site", item.site);
            ARouterUtils.toActivity(ARouterConfig.SUB_CATEGORY_LIST, map);
        });
    }
}
